package com.sunwayhorizo.health.platform.util;

import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Properties;

import org.jboss.seam.Component;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;

@Name("propertiesUtil")
@Scope(ScopeType.APPLICATION)
public class PropertiesUtil{

	private static Properties prop;
	static {
		synchronized (PropertiesUtil.class) {
			prop = new Properties();
			InputStream is = PropertiesUtil.class.getResourceAsStream("/systemDataInit.properties");
			if (is == null) {
				throw new RuntimeException("can not found the file telehealth.properties");
			}
			try {
				prop.load(new InputStreamReader(is,"UTF-8"));
				is.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}

	public Properties getProperties() {
		return prop;
	}

	public static PropertiesUtil instance() {
		return (PropertiesUtil) Component.getInstance(PropertiesUtil.class,ScopeType.APPLICATION);
	}
}
